class NumTransLatePlugin{

    static chnNumChar = ["零","一","二","三","四","五","六","七","八","九"];
    static chnUnitSection = ["","万","亿","万亿","亿亿"];
    static chnUnitChar = ["","十","百","千"];

    constructor() {

    }
    static SectionToChinese(section){
        var strIns = '' , chnStr = '' ;
        var unitPos = 0;
        var zero = true ;
        while (section > 0){
            var v = section % 10;
            if (v === 0){
                if (!zero){
                    zero = true ;
                    chnStr = chnNumChar[v] + chnStr;
                }
            } else {
                zero = false ;
                strIns = chnNumChar[v];
                strIns += chnUnitChar[unitPos];
                chnStr = strIns + chnStr;
            }
            unitPos++;
            section = Math.floor(section / 10);
        }
        return chnStr;
    }


    static ChineseToNumber(chnStr){
        let str = chnStr.split( '' );
        let numStr="";
        for ( var i = 0; i < str.length; i++){
            let c=str[i];
            let k=1;
            if(i==0 && c=="十"){
                k=1;
                numStr=numStr+k;
                continue
            }
            let cindex= chnNumChar.indexOf(c);
            if(cindex!=-1){
                k=cindex;
                numStr=numStr+k;
                continue
            }
        }
        return numStr;
    }


}

export default NumTransLatePlugin;